package com.gzhryc.shared_device.oem.code.place.dao;

import java.sql.SQLException;
import java.util.List;

import com.gzhryc.jdbc.BaseDao;
import com.gzhryc.jdbc.Conditions;
import com.gzhryc.jdbc.Query;
import com.gzhryc.shared_device.oem.code.place.dao.db.ClerkFuncModel;
import com.gzhryc.shared_device.oem.code.place.dao.models.ClerkFuncModelCount;

public class ClerkFuncModelDao extends BaseDao<ClerkFuncModel> {

    public ClerkFuncModelDao(String jdbcKey) {
        super(jdbcKey);
    }

    public List<ClerkFuncModelCount> countGroupMerchantAndUserId(Conditions conditions) throws SQLException {
        String sql = "SELECT merchant_user_id AS merchantUserId,user_id AS userId,user_id AS userId,COUNT(1) AS funcModelCount FROM " + this.tableName;
        Query query = new Query(sql);
        query.appendSql(conditions.toSql(query.getParams(),true));
        query.appendSql(" GROUP BY merchant_user_id,user_id");
        return this.jdbcHelper.find(query,ClerkFuncModelCount.class);
    }
}
